feat(html-report): baked-in C# syntax highlighting on Source tab#6132
Merged
thomhurst merged 1 commit intoMay 31, 2026
Merged
Conversation
Add a small, zero-dependency C# syntax highlighter to the HTML test report's Source tab. A hand-rolled tokenizer classifies comments, strings (regular/verbatim/interpolated/raw), char and numeric literals, keywords, method calls and PascalCase types, emitting theme-aware token spans. Token colors are driven by --syn-* CSS custom properties defined per theme, so highlighting follows the existing light/dark toggle with no re-render. The palette matches the docs site's Prism themes (github for light, dracula for dark). Non-.cs files fall back to plain escaped text. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
Contributor
Author
|
The alternative is something like highlight.js and we reference that, this would be more accurate in terms of highlighting |
Owner
|
Nice! 😄 |
1 task
This was referenced Jun 1, 2026
This was referenced Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a small, zero-dependency C# syntax highlighter to the HTML test report's Source tab. Previously the fetched source was rendered as plain, uncolored text.
How
highlightCSharpLines) classifies comments (line/block/XML-doc), strings (regular, verbatim@"…", interpolated$"…", raw"""…"""including multi-line), char and numeric literals (hex/binary/float suffixes/digit separators), keywords, method calls (ident() and PascalCase types.esc().--syn-*CSS custom properties defined per theme, so highlighting follows the existing light/dark toggle instantly with no JS re-render..csfiles fall back to plain escaped text.All changes live in the embedded
TestReport.template.htmlresource, outside theSAMPLE_DATAmarkers and__REPORT_DATA__placeholder, so report generation is unaffected. No C# changes, no new dependencies.Preview
Light (github) / Dark (dracula), switching with the theme toggle:
#00009f, types#6f42c1, strings#e3116c, comments#999988italic, numbers#36acaa, calls#d73a49#bd93f9, types#8be9fd, strings#ff79c6, comments#6272a4, numbers#bd93f9, calls#50fa7bNotes
value, LINQ query words, etc.) are intentionally excluded to avoid miscoloring.🤖 Generated with Claude Code